home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freaks Macintosh Archive
/
Freaks Macintosh Archive.bin
/
Freaks Macintosh Archives
/
Hacking & Misc
/
Mac Satellite.sit
/
Mac Satellite
/
MacSeason9 v1.7
/
MacSeason9v1.7
/
MacSeason9.src
/
vcDialogs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-14
|
5KB
|
206 lines
#include "MacSeason9.h"
extern vcPrefs prgPrefs;
extern unsigned long shutDownTime;
extern unsigned char *msgStrings[10];
void StateDispatch( void );
void LoadPrefs( void )
{
Handle theRes;
theRes=GetResource(PREFRESTYPE,PREFRESID);
if (theRes) {
HLock(theRes);
BlockMove(*theRes, &prgPrefs, sizeof(prgPrefs) );
HUnlock(theRes);
ReleaseResource(theRes);
} else { /* build preferences the first time */
prgPrefs.decode = 0; /* No decode delay */
prgPrefs.processReset = 140; /* Reset Delay = 140 */
prgPrefs.byte = 0; /* No Byte Delay */
prgPrefs.kernelCount = 999; /* No please wait bytes */
prgPrefs.whichPort = kPortA; /* Use port A (modem) */
prgPrefs.debug = 0; /* Don't show Traffic Info window */
prgPrefs.tvMsgs = 1; /* Display messages on TV */
prgPrefs.fullDecode = 1; /* Decode wether answer is required or not */
prgPrefs.endless = 0; /* Allow background tasks */
prgPrefs.normDisplay = 0; /* Minimal display on computer */
}
}
void SavePrefs( void )
{
Handle theRes;
theRes=GetResource(PREFRESTYPE,PREFRESID);
if (GetHandleSize(theRes) != sizeof(prgPrefs) ) {
SetHandleSize(theRes, sizeof(prgPrefs));
}
if (theRes) {
HLock(theRes);
BlockMove(&prgPrefs,*theRes, sizeof(prgPrefs) );
HUnlock(theRes);
ChangedResource(theRes);
} else {
theRes=NewHandle(sizeof(prgPrefs));
HLock(theRes);
BlockMove(&prgPrefs,*theRes, sizeof(prgPrefs) );
HUnlock(theRes);
AddResource(theRes,PREFRESTYPE,PREFRESID, msgStrings[0]);
}
WriteResource(theRes);
ReleaseResource(theRes);
}
pascal void MyItemProc(WindowPtr theDlg, short theItem)
{
Rect iRect;
Handle iHndl;
short iType;
GetDItem(theDlg,1,&iType,&iHndl,&iRect);
PenSize(3,3);
InsetRect(&iRect,-4,-4);
FrameRoundRect(&iRect,16,16);
}
pascal Boolean MyDlgFilter(DialogPtr theDlg,EventRecord *theEvent, short *itemHit )
{
unsigned char theChar;
StateDispatch();
if ( theEvent->what != keyDown )
return(FALSE);
theChar=(theEvent->message) & charCodeMask;
if ((theChar==0x0D)||(theChar==0x03)) {
*itemHit=ok;
return(TRUE);
} else {
if ((theChar==0x1B)||((theChar==0x2E)&&((theEvent->modifiers) & cmdKey))) {
*itemHit = cancel;
return( TRUE );
}
}
return(FALSE);
}
void SetPrefs(void)
{
GrafPtr savePort;
DialogPtr myDlg;
short theItem;
short iType;
Handle iHandle;
Rect iRect;
short checkBox[20], radioButton;
Str255 numStr;
long theNum;
GetPort(&savePort);
myDlg=GetNewDialog(dlgDelays, 0L,(WindowPtr) -1L);
GetDItem(myDlg,3,&iType,&iHandle,&iRect);
SetDItem(myDlg,3,iType, (ProcPtr )MyItemProc,&iRect);
checkBox[dlyDecode] = prgPrefs.decode;
checkBox[dlyReset] = prgPrefs.processReset;
checkBox[dlyByte] = prgPrefs.byte;
checkBox[dlyKernCnt]= prgPrefs.kernelCount;
for (theItem = dlyFirstInp; theItem <= dlyLastInp; theItem++ ) {
theNum=(long )checkBox[theItem];
NumToString(theNum, numStr);
GetDItem(myDlg, theItem, &iType, &iHandle, &iRect);
SetIText(iHandle, numStr);
}
radioButton = prfModem + prgPrefs.whichPort;
GetDItem(myDlg, prfModem, &iType, &iHandle, &iRect);
SetCtlValue((ControlHandle)iHandle, (radioButton == prfModem));
GetDItem(myDlg, prfPrinter, &iType, &iHandle, &iRect);
SetCtlValue((ControlHandle)iHandle, (radioButton == prfPrinter));
SelIText(myDlg,dlyDecode, 0, 32767);
SetPort(myDlg);
ShowWindow(myDlg);
do {
ModalDialog( MyDlgFilter, &theItem);
switch (theItem) {
case prfModem:
case prfPrinter:
radioButton = theItem;
GetDItem(myDlg, prfModem, &iType, &iHandle, &iRect);
SetCtlValue((ControlHandle)iHandle, (radioButton == prfModem));
GetDItem(myDlg, prfPrinter, &iType, &iHandle, &iRect);
SetCtlValue((ControlHandle)iHandle, (radioButton == prfPrinter));
break;
}
} while (theItem>2);
if (theItem==ok) {
for (theItem = dlyFirstInp; theItem <= dlyLastInp; theItem++ ) {
GetDItem(myDlg, theItem, &iType, &iHandle, &iRect);
GetIText(iHandle, numStr);
StringToNum(numStr, &theNum);
checkBox[theItem] = theNum;
}
prgPrefs.decode = checkBox[dlyDecode];
prgPrefs.processReset = checkBox[dlyReset];
prgPrefs.byte = checkBox[dlyByte];
prgPrefs.kernelCount = checkBox[dlyKernCnt];
radioButton -= prfModem;
if (radioButton != prgPrefs.whichPort) {
prgPrefs.whichPort = radioButton;
CloseDownSerials();
InitializeVC(prgPrefs.whichPort);
}
}
DisposDialog(myDlg);
SetPort(savePort);
}
void SetShutdown(void)
{
GrafPtr savePort;
DialogPtr myDlg;
short theItem;
short iType;
Handle iHandle;
Rect iRect;
long shutdownValue;
Str255 numStr;
long theNum;
GetPort(&savePort);
myDlg=GetNewDialog(dlgShutdown, 0L,(WindowPtr) -1L);
GetDItem(myDlg,3,&iType,&iHandle,&iRect);
SetDItem(myDlg,3,iType, (ProcPtr )MyItemProc,&iRect);
shutdownValue = 120;
NumToString(shutdownValue, numStr);
GetDItem(myDlg, shdTime, &iType, &iHandle, &iRect);
SetIText(iHandle, numStr);
SelIText(myDlg, shdTime, 0, 32767);
SetPort(myDlg);
ShowWindow(myDlg);
do {
ModalDialog( MyDlgFilter, &theItem);
} while (theItem>2);
if (theItem==ok) {
GetDItem(myDlg, shdTime, &iType, &iHandle, &iRect);
GetIText(iHandle, numStr);
StringToNum(numStr, &shutdownValue);
shutDownTime = (shutdownValue << 6);
shutDownTime -= (shutdownValue << 2); /* * (64 - 4) */
shutDownTime += Time;
} else {
shutDownTime = 0;
}
DisposDialog(myDlg);
SetPort(savePort);
}